package com.p7.framework.permission.shiro.session;

import java.io.Serializable;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.p7.framework.permission.shiro.utils.ExpireBusinessUtils;
import org.apache.shiro.session.mgt.SimpleSession;

/**
 * 自定义session，第一次创建session时更新到redis中，之后如果本地缓存失效，会更新redis缓存（redis失效时间）
 * 之后只要是更改session属性，都会触发redis缓存更新和cache更新
 * @author Yangzhen
 * @Description
 * @date 2019-02-13 15:45
 **/
public class ClientSession extends SimpleSession implements Serializable {

	private static final long serialVersionUID = -7324433245899633633L;

	@Override
	protected void expire() {
		super.expire();
		doExpireBusiness();
	}

	public void doExpireBusiness() {
		if (ExpireBusinessUtils.expireBusinessFacade != null) {
			ExpireBusinessUtils.expireBusinessFacade.expire(getAttributes());
			System.out.println(JSON.toJSONString(this));
		}
	}
}
